<?php
/**
 * Displays an import form to allow for upload & process of reference file
 * @copyright &copy; 2009 The Open University
 * @author j.platts@open.ac.uk
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
 * @package resourcepage
 */

global $CFG;


require_once($CFG->libdir.'/formslib.php');

class resourcepage_addreferences_form extends moodleform {

    function definition() {

        global $COURSE;
        $mform    =& $this->_form;

        //-------------------------------------------------------------------------------
        // Add General box
        $mform->addElement('header', 'general', get_string('general', 'form'));

        $this->set_upload_manager(new upload_manager('attachment', true, false, $COURSE, false, 512000 , true, true, false));
        $mform->addElement('file', 'attachment', get_string('reference_file', 'resourcepage'));
        $mform->addRule('attachment', null, 'required');

        // Add sorting
        $radio = array();
        $radio[] = &MoodleQuickForm::createElement('radio', 'sorting', null, get_string('reference_none', 'resourcepage'), 0);
        $radio[] = &MoodleQuickForm::createElement('radio', 'sorting', null, get_string('reference_author', 'resourcepage'), 1);
        $radio[] = &MoodleQuickForm::createElement('radio', 'sorting', null, get_string('reference_title', 'resourcepage'), 2);
        $mform->addGroup($radio, 'sorting',  get_string('reference_sorting', 'resourcepage'), ' ', false);
        //$mform->setHelpButton('feedupdates', array('feedupdates', get_string('feedupdates', 'resourcepage_rssfeed', NULL, dirname(__FILE__).'/lang/'), 'resourcepage_rssfeed'));
        $mform->setDefault('sorting', 0);

        //back func (as per weblink)
        $select = &$mform->addElement('select', 'backbroken', get_string('field_backbroken','resourcepage'), array(get_string('backbuttonok','resourcepage'), get_string('backbuttonbroken','resourcepage')));
        $select->setMultiple(false);
        
        
        //Resctrict
        //if (!empty($CFG->enableavailability)) {
        // Conditional availability
        $mform->addElement('header', '', get_string('availabilityconditions', 'condition'));
        $mform->addElement('date_selector', 'availablefrom', get_string('availablefrom', 'condition'), array('optional'=>true));
        $mform->setHelpButton('availablefrom', array('conditiondates', get_string('help_conditiondates', 'condition'), 'condition'));
        $mform->addElement('date_selector', 'availableuntil', get_string('availableuntil', 'condition'), array('optional'=>true));
        $mform->setHelpButton('availableuntil', array('conditiondates', get_string('help_conditiondates', 'condition'), 'condition'));
        //}



        // Add hidden elements

        $mform->addElement('hidden', 'containerid', null);
        $mform->addElement('hidden', 'coursemodule', null);

        //-------------------------------------------------------------------------------
        // Add Save Changes and Cancel buttons
        $this->add_action_buttons(true,get_string('reference_addtitle','resourcepage'));
    }
}
?>